﻿using Furion.DependencyInjection;
using RabbitMQ.Client;
using VOL.RabbitMq.IRabbitMq;

namespace VOL.RabbitMq.RabbitMq.Handler
{
    /// <summary>
    /// 机器人消息数据处理器
    /// </summary>
    public class RabbitMqMessageHandler : BaseHandler, IRabbitMqMessageHandler, ITransient
    {
        #region 变量



        #endregion

        #region 属性

        /// <summary>
        /// 描述
        /// </summary>
        public override string Description => "机器人消息数据处理器";

        #endregion

        #region 构造函数

        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="serviceProvider">服务提供者</param>
        public RabbitMqMessageHandler(IServiceProvider serviceProvider) : base(serviceProvider)
        {

        }

        #endregion

        #region 接口实现

        /// <summary>
        /// 主题负载异步处理器
        /// </summary>
        /// <param name="client">MQTT客户端</param>
        /// <param name="topic">订阅主题</param>
        /// <param name="payloadContent">负载内容</param>
        /// <param name="isSys">是否系统</param>
        /// <returns></returns>
        public async Task<bool> TopicPayloadAsyncHandler(IModel client, string ExchangeName, string queuename, string payloadContent)
        {
            try
            {

                return true;
                //// 切割订阅主题，获取设备标识
                //string clientId = topic.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[^2];
                //// 如果客户端Id以Client开头，直接返回
                //if (clientId.StartsWith("Client", StringComparison.OrdinalIgnoreCase)) return;
                //// 获取机器人标识
                //long.TryParse(topic.Split(new char[] { '/' }, StringSplitOptions.RemoveEmptyEntries)[^2], out long socketId);

                //await Console.Out.WriteLineAsync($"客户端({socketId})处理中: TOPIC--{topic}, payloadContent--{payloadContent}");

                //// 发布信息
                //await client.PublishAsync($"/device/realtime/{clientId}", mCommonModule.JsonConvert.ToJson(socketId));
                //
            }
            catch (Exception)
            {

            }

            return await Task.FromResult(true);
        }

        #endregion

        #region 函数



        #endregion
    }
}
